﻿using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class Item_box : MonoBehaviour,IPointerEnterHandler, IPointerExitHandler
{
	public GameObject item = null;
	public GameObject light_box;
	private bool hover = false;

	public int item_ID = 0;
	public int  num = 0;
	public int max_num = 20;

	public void swap_date(Item_box a)
	{
		if (!a) 
		{
			return;
		}
		int ver;
		GameObject gobj;

		gobj = a.item;
		a.item = this.item;
		this.item = gobj;

		ver = a.item_ID;
		a.item_ID = this.item_ID;
		this.item_ID = ver;

		ver = a.num;
		a.num = this.num;
		this.num = ver;

		ver = a.max_num;
		a.max_num = this.max_num;
		this.max_num = ver;
	}

	void OnDisable()
	{
		hover = false;
		light_box.SetActive(false);
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		hover = false;
		light_box.SetActive(false);
	}
	public void OnPointerEnter(PointerEventData eventData)
    {
    	hover = true;
    	light_box.SetActive(true);
    }
	//private int Quality;
	// Use this for initialization
	void Start () {
		max_num = 20;
		num = 0;
		item_ID = 0;
		light_box.SetActive(false);
	}
	
	// Update is called once per frame
	void Update ()
	{
		if (hover) 
		{
			light_box.transform.position = Vector3.Lerp(
				light_box.transform.position,
				transform.position,
				15f * Time.deltaTime
			);
		}
	}
}
